package com.dajun.config;

import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.spring.boot.EngineConfigurationConfigurer;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;

import javax.annotation.Resource;

/**
 * flowable配置项 指定采用mysql数据库
 */
@Configuration
public class FlowableConfig implements EngineConfigurationConfigurer<SpringProcessEngineConfiguration> {

    @Resource
    private PlatformTransactionManager transactionManager;

    @Override
    public void configure(SpringProcessEngineConfiguration config) {
        // 关键配置：绑定 Spring 事务管理器
        config.setTransactionManager(transactionManager);

        // 其他必要配置
        config.setDatabaseSchemaUpdate("true"); // 自动更新表结构
        config.setAsyncExecutorActivate(true);  // 启用异步执行器
        config.setDatabaseType("mysql"); // 明确指定数据库类型
    }
}